# Redis主节点配置文件
bind 0.0.0.0
protected-mode yes
port {{ redis_port_master }}
tcp-backlog 511
timeout 0
tcp-keepalive 300

# 守护进程
daemonize no
supervised systemd
pidfile /var/run/redis_{{ redis_port_master }}.pid
loglevel notice
logfile {{ redis_log_dir }}/redis-{{ redis_port_master }}.log
databases 16

# 持久化
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump-{{ redis_port_master }}.rdb
dir {{ redis_data_dir }}/{{ redis_port_master }}

# 密码
requirepass {{ redis_password }}
masterauth {{ redis_password }}

# 最大内存
maxmemory 2gb
maxmemory-policy allkeys-lru

# AOF持久化
appendonly yes
appendfilename "appendonly-{{ redis_port_master }}.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

# 集群配置
cluster-enabled yes
cluster-config-file nodes-{{ redis_port_master }}.conf
cluster-node-timeout 15000
cluster-replica-validity-factor 10
cluster-migration-barrier 1
cluster-require-full-coverage no

# 慢查询日志
slowlog-log-slower-than 10000
slowlog-max-len 128

# 客户端限制
maxclients 10000
